﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RBAC.Api.Demain.ContentManagement;
using RBAC.Api.Erroc;
using RBAC.Api.Read.Command.ContentManagement;
using RBAC.Api.Read.Dto;

namespace RBAC.Api.Read.Controllers.ContentManagement
{
    /// <summary>
    /// 轮播图表管理控制器--读
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CarouselChartController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;

        public CarouselChartController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取轮播图表
        /// </summary>
        /// <param name="title"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<APIPagin<CarouselChartModel>>> ShowCarouselChart(string? title, DateTime? startTime, DateTime? endTime, int pageIndex, int pageSize)
        {
            ShowCarouselChartCommand command = new ShowCarouselChartCommand();
            command.Title = title;
            command.StartTime = startTime;
            command.EndTime = endTime;
            command.PageIndex = pageIndex;
            command.PageSize = pageSize;
            return mediator.Send(command);
        }
        /// <summary>
        /// 获取科室列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<CascadeItem>>> GetDepartments()
        {
            return mediator.Send(new GetDepartmentsCommand());
        }
    }
}
